package yannan.voiplock4ble.view;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.ProgressBar;

import com.github.ybq.android.spinkit.style.Wave;

import yannan.voiplock4ble.R;


/**
 * <p>name:</p>
 * <p>describe:</p>
 *
 * @author Maintel
 * @time 2016/9/10 11:34
 */
public class MyProgressDialog extends ProgressDialog {

    Context mContext;
    static MyProgressDialog dialog;

    public MyProgressDialog(Context context, int theme) {
        super(context, theme);
        mContext = context;
    }

    public MyProgressDialog(Context context) {
        super(context);
        mContext = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ProgressBar progressBar = new ProgressBar(mContext);
//        DoubleBounce doubleBounce = new DoubleBounce();
        Wave wave = new Wave();
        progressBar.setIndeterminateDrawable(wave);
        setContentView(progressBar);
    }

    public static void showPro(Context mContext, boolean b) {
        dialog = new MyProgressDialog(mContext, R.style.progress_dialog);
        dialog.setCanceledOnTouchOutside(b);
        dialog.setCancelable(b);
        dialog.show();

//        return dialog;
    }

    public static void dismissDialog() {
        if (dialog != null) {
            if (dialog.isShowing()) {
                dialog.dismiss();
                dialog = null;
            }
        }
    }
}
